package Thread;

//
class Singleton{
    private static Singleton instance = new Singleton();
    // 直接在类内部实例化

    public static Singleton getInstance(){
        return instance;
    }
    private Singleton(){}
    // 将构造方法私有话, 在外部是不能new()的

}
public class ThreadDemo1 {
    public static void main(String[] args) {
//        Singleton s = new Singleton();

        Singleton s = Singleton.getInstance();
        Singleton s1 = Singleton.getInstance();
        System.out.println(s==s1);
    }
}
